#include	"DBFlushApp.h"
#include	"DBFlushService.h"

#include	<IniFile.h>
#include	<Logger.h>

bool DBFlushApp::OnInit(Command & cmd) {
	IniFile conf;
	if (!conf.Load("config.ini")) throw std::runtime_error("Failed to load config.ini");

	int log_level = conf.Get<int>("dbflush", "log_level", ELog::Info);
	Logger::Instance().Init("dbflush", "logs", 4194304, (ELog::Level)log_level);

	return GService.Initialize(conf);
}

void DBFlushApp::OnBreath() {
	GService.Breath();
}

void DBFlushApp::OnExit(int code) {
	LOG_INFO("Application dbflush exist(%d) ...", code);
	GService.Quit();
}

RUN_APP(DBFlushApp)